//
//  YMHomeFileAndVideoCell.m
//  YMMedical
//
//  Created by y s on 2023/7/19.
//

#import "YMHomeFileAndVideoCell.h"
#import "YMOperateVideoViewController.h"
#import "YMHealthFileViewController.h"

@interface YMHomeFileAndVideoCell ()

@property (nonatomic, strong) UIButton *btnFile;
@property (nonatomic, strong) UIImageView *imgvFile;
@property (nonatomic, strong) UILabel *lblFile;

@property (nonatomic, strong) UIButton *btnVideo;
@property (nonatomic, strong) UIImageView *imgvVideo;
@property (nonatomic, strong) UILabel *lblVideo;

@end


@implementation YMHomeFileAndVideoCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setUI];
    }
    return self;
}

#pragma mark - UI methods
- (void)setUI{
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    self.contentView.backgroundColor = [UIColor clearColor];
    self.backgroundColor = [UIColor clearColor];
    
    [self.contentView addSubview:self.btnFile];
    [self.btnFile addSubview:self.imgvFile];
    [self.btnFile addSubview:self.lblFile];
    [self.contentView addSubview:self.btnVideo];
    [self.btnVideo addSubview:self.imgvVideo];
    [self.btnVideo addSubview:self.lblVideo];
    
    [self.btnFile mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo([SFitUtil fit:15]);
        make.top.bottom.mas_equalTo(0);
    }];
    [self.btnVideo mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo([SFitUtil fit:-15]);
        make.top.bottom.mas_equalTo(0);
        make.left.equalTo(self.btnFile.mas_right).offset([SFitUtil fit:15]);
        make.width.equalTo(self.btnFile);
    }];
    [self.imgvFile mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo([SFitUtil fit:16]);
        make.centerY.mas_equalTo(0);
        make.size.mas_equalTo([SFitUtil fitSize:45 height:45]);
    }];
    [self.lblFile mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(0);
        make.left.equalTo(self.imgvFile.mas_right).offset([SFitUtil fit:5]);
        make.right.mas_equalTo([SFitUtil fit:-5]);
    }];
    [self.imgvVideo mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo([SFitUtil fit:16]);
        make.centerY.mas_equalTo(0);
        make.size.mas_equalTo([SFitUtil fitSize:45 height:45]);
    }];
    [self.lblVideo mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(0);
        make.left.equalTo(self.imgvVideo.mas_right).offset([SFitUtil fit:5]);
        make.right.mas_equalTo([SFitUtil fit:-5]);
    }];
}

#pragma mark - public methods
+ (CGFloat)getCellHeight{
    return [SFitUtil fit:70];
}

- (void)updateLanguage{
    _lblVideo.text = KLanguage(@"operate_video_txt");
    _lblFile.text = KLanguage(@"health_docu_txt");
}


#pragma mark - Event Action
- (void)fileClickAction:(id)sender{
    if (self.testeeId == nil || self.testeeId.length < 1){
        [SHUD showInfo:KLanguage(@"choose_testee_txt")];
        return;
    }
    YMHealthFileViewController *vc = [[YMHealthFileViewController alloc] init];
    vc.testeeId = self.testeeId;
    vc.idStr = self.idStr;
    vc.maxIdStr = self.maxIdStr;
    vc.hidesBottomBarWhenPushed = YES;
    [SJumpUtil pushVC:vc animated:YES];
}
- (void)videoClickAction:(id)sender{
    YMOperateVideoViewController *vc = [[YMOperateVideoViewController alloc] init];
    vc.idStr = _idStr;
    vc.hidesBottomBarWhenPushed = YES;
    [SJumpUtil pushVC:vc animated:YES];
}

#pragma mark - setter and getter
- (UIButton *)btnFile{
    if (_btnFile == nil){
        _btnFile = [UIButton buttonWithType:UIButtonTypeCustom];
        [_btnFile addTarget:self action:@selector(fileClickAction:) forControlEvents:UIControlEventTouchUpInside];
        _btnFile.clipsToBounds = YES;
        _btnFile.layer.cornerRadius = [SFitUtil fit:8];
        _btnFile.backgroundColor = STheme.D9;
    }
    return _btnFile;
}
- (UIImageView *)imgvFile{
    if (_imgvFile == nil){
        _imgvFile = [[UIImageView alloc] init];
        _imgvFile.image = [UIImage imageNamed:@"home_health_file_icon"];
    }
    return _imgvFile;
}
- (UILabel *)lblFile{
    if (_lblFile == nil){
        _lblFile = [[UILabel alloc] init];
        _lblFile.text = KLanguage(@"health_docu_txt");
        _lblFile.textColor = STheme.D1;
        _lblFile.font = [SFitUtil fitBoldFont:16];
        _lblFile.textAlignment = NSTextAlignmentCenter;
    }
    return _lblFile;
}
- (UIButton *)btnVideo{
    if (_btnVideo == nil){
        _btnVideo = [UIButton buttonWithType:UIButtonTypeCustom];
        [_btnVideo addTarget:self action:@selector(videoClickAction:) forControlEvents:UIControlEventTouchUpInside];
        _btnVideo.clipsToBounds = YES;
        _btnVideo.layer.cornerRadius = [SFitUtil fit:8];
        _btnVideo.backgroundColor = STheme.D9;
    }
    return _btnVideo;
}
- (UIImageView *)imgvVideo{
    if (_imgvVideo == nil){
        _imgvVideo = [[UIImageView alloc] init];
        _imgvVideo.image = [UIImage imageNamed:@"home_caozuo_video_icon"];
    }
    return _imgvVideo;
}
- (UILabel *)lblVideo{
    if (_lblVideo == nil){
        _lblVideo = [[UILabel alloc] init];
        _lblVideo.text = KLanguage(@"operate_video_txt");
        _lblVideo.textColor = STheme.D1;
        _lblVideo.font = [SFitUtil fitBoldFont:16];
        _lblVideo.textAlignment = NSTextAlignmentCenter;
    }
    return _lblVideo;
}


@end
